/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-30 10:45:39
 * @LastEditTime : 2023-06-07 08:54:59
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\PersonStatistics.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { PersonTypeTree } from '../Common/Conversion'
import { SaveExcelButton, SelectExcelButton } from '../Common/options'

export const PersonStatistics = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const parentUuid = await PersonTypeTree()
    let data = {
        type: '人员管理',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`getAttendanceStatistics`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <SaveExcelButton key="excel" title="导出Excel" api={API_LIST()['getAttendanceStatistics']} />,
            <SelectExcelButton
                key="excelTwo"
                title="按月导出考勤"
                OptionsEvent={OptionsEvent}
                api={API_LIST()['getAttendancesAttendanceExcel']}
                data={{ date: 'YYYY-MM-DD' }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            { ...commonTableList.tableName, title: '姓名' },
            {
                dataIndex: 'personTypeUuid',
                title: '人员类别',
                valueType: 'treeSelect',
                fieldProps: {
                    options: parentUuid,
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                hideInSearch: true,
                hideInTable: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'personTypeName',
                title: '人员类别',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'emergenceMobile',
                title: '联系电话',
                valueType: 'input',
            },
            {
                dataIndex: 'attendanceCount',
                title: '打卡次数',
                valueType: 'inputNumber',
                rules: true,
                render: e => <div>{e} 次</div>,
                hideInSearch: true,
            },
            {
                dataIndex: 'departmentUuid',
                title: '部门',
                valueType: 'select',
                valueEnum: ClientData.dictionary['a2891f3b-3811-4b8b-8dbb-832096e3174e'],
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'positionUuid',
                title: '岗位',
                valueType: 'select',
                valueEnum: ClientData.dictionary['d4d706cd-1538-456b-90da-d061195c8aa6'],
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'rankUuid',
                title: '职务级别',
                valueType: 'select',
                valueEnum: ClientData.dictionary['d83de24e-191d-4646-b742-55ad694a3747'],
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'categoryUuid',
                title: '人员性质',
                valueType: 'select',
                valueEnum: ClientData.dictionary['51297964-6295-475a-8219-d3f9a4568fe6'],
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'AttendanceCountGte',
                title: '最大考勤',
                valueType: 'inputNumber',
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            {
                dataIndex: 'AttendanceCountLte',
                title: '最小考勤',
                valueType: 'inputNumber',
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            commonTableList.BeginAttendanceTime,
            commonTableList.EndAttendanceTime,
        ],
    }

    return data
}
